package cn.zhaoyuening.fanblog.admin.service.impl;

import org.springframework.stereotype.Service;

import cn.zhaoyuening.fanblog.admin.service.ArticleTypeService;
import cn.zhaoyuening.fanblog.common.domain.ArticleType;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ArticleTypeServiceImpl extends BaseServiceImpl<ArticleType,Long> implements ArticleTypeService{

	@Override
	public boolean update(ArticleType type) {
		if (type == null || type.getId() == null) {
			return false;
		}
		ArticleType oldType = getRepository().getOne(type.getId());
		if (type.getName() != null) {
			oldType.setName(type.getName());
		}
		if (type.getCount() != null) {
			oldType.setCount(type.getCount());
		}
		ArticleType newType = getRepository().saveAndFlush(oldType);

		return newType != null;
	}





}
